home *** CD-ROM | disk | FTP | other *** search
/ DOpus Plus / DOpus Plus.iso / Tutorial / C Guide / Simple_Module2 / ExampleRequest.c < prev    next >
C/C++ Source or Header  |  1998-08-22  |  2KB  |  70 lines

  1. /*******************************************************************
  2.  
  3.    ExampleRequest.c
  4.     
  5.     Some Notes:
  6.     
  7.     I write my defines all in uppercase.
  8.     All defines starting with "MSG_" are from the buildin.cd.
  9.  
  10. *********************************************************************/
  11.  
  12. #include "includes/ExampleRequest.h"
  13.  
  14.  
  15. void ExampleRequest( STRPTR args, struct Screen *screen, IPCData *ipc )
  16. {
  17.      ERData *erd;
  18.      
  19.       // allocate some memory from our globally pool
  20.      if( (erd = AllocMemH(mempool, sizeof(ERData))) )
  21.        {             
  22.              if( *args )
  23.                {
  24.                     erd->ptr_read = args;
  25.              
  26.                   // going to the end of the args
  27.                   while( *erd->ptr_read++ );
  28.                     
  29.                     // it does point at least at the "\0" of the string,
  30.                     // Jonathan does also append a some other stuff, we
  31.                     // want this not at this stage :-)
  32.                     erd->ptr_read -= 3;
  33.                     
  34.                     // Now we can make a reversed copy
  35.                     erd->ptr_write = erd->buffer;
  36.                     
  37.                     while( ((ULONG) erd->ptr_read) >= ((ULONG) args) )
  38.                       {
  39.                             *erd->ptr_write++ = *erd->ptr_read--; 
  40.                           erd->count++;
  41.                       }
  42.                   
  43.                     // since we have used our memorypool with the flag
  44.                     // MEMF_CLEAR and we have not used it before, we must
  45.                     // not append a "\0" to erd->buffer
  46.                 }    
  47.             
  48.             sprintf( erd->output, "%s : %s%s : %s\n%s : %ld",
  49.                      DOpusGetString( locale, MSG_ARGUMENTS ), args,
  50.                         DOpusGetString( locale, MSG_REVERSED ), erd->buffer, 
  51.                         DOpusGetString( locale, MSG_COUNTED ), erd->count );
  52.                
  53.             // now we are ready to open our requester
  54.             // we do not check here the result, but should be at least
  55.             // no problem for you...
  56.             
  57.             AsyncRequestTags( ipc, REQTYPE_SIMPLE, NULL, NULL, NULL,
  58.                               
  59.                                     AR_Screen,  screen,
  60.                                     AR_Title,   DOpusGetString(locale, MSG_ER_TITLE),
  61.                                     AR_Message, erd->output,
  62.                                     AR_Button,  DOpusGetString(locale, MSG_OKAY_BUTTON),
  63.                                     TAG_DONE );
  64.                                     
  65.             // free our memory
  66.             FreeMemH( erd );
  67.        }
  68. }
  69.  
  70.